import {
  defineConfig,
  presetAttributify,
  presetIcons,
  presetUno,
} from "unocss";
import presetRemToPx from "@unocss/preset-rem-to-px"; // rem转pxunocss默认是rem 1rem=16px
export default defineConfig({
  shortcuts: [],
  theme: {
    colors: {
      background: "#f7f7f7",
      primary: "var(--el-color-primary)",
      success: "var(--el-color-success)",
      warning: "var(--el-color-warning)",
      danger: "var(--el-color-danger)",
      error: "var(--el-color-error)",
      info: "var(--el-color-info)",
    },
  },
  rules: [
    [
      /^text-(.*)$/,
      ([, c], { theme }: { theme: any }) => {
        if (theme.colors[c]) return { color: theme.colors[c] };
      },
    ],
    [/^w%-(\d+)$/, ([, d]) => ({ width: d + '%' })], // 宽 100%
    [/^h%-(\d+)$/, ([, d]) => ({ height: d + '%' })], // 高 100%
    [/^text-size-(\d+)$/, ([, d]) => ({ 'font-size': d + 'px' })], // 字体大小
    [/^line-height-(\d+)$/, ([, d]) => ({ 'line-height': d + 'px' })], // 行高
    [/^size-(\d+)$/, ([, d]) => ({ width: d + 'px', height: d + 'px'})], // 宽高
  ],
  presets: [
    presetRemToPx({ baseFontSize: 4}),
    presetIcons(),
    presetAttributify(),
    presetUno(),
  ],
  transformers: [],
});
